package org.bot.server.client.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bot.server.client.entity.BotClient;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author 沧月
 * @create 0020 2023/9/20 09:42
 * @description <description class purpose>
 */
@Mapper
@Repository
public interface BotClientMapper extends BaseMapper<BotClient> {


    @Select("<script>select id,name,creation_date,status,client_id,activate_code,task_queue,task_active from bot_client <where><if test='name!=null'> name like concat('%',#{name},'%') </if></where> order by id desc limit #{page},#{size}</script>")
    public List<BotClient> list(@Param("name") String name,@Param("page") int page,@Param("size") int size);

    @Select("<script>select count(1) as num from bot_client <where><if test='name!=null'> name like concat('%',#{name},'%') </if></where></script>")
    public int listCount(@Param("name") String name);

    @Select("select id,name,creation_date,status,client_id,secret,activate_code,device_id,activate_status from bot_client where status <> 3 and client_id = #{clientId} limit 1")
    Map<String, Object> getBotFlowInfo(@Param("clientId") String clientId);
}
